﻿@model PresentationMVC.Models.StaffDataModel
@{
    
    var grid = new WebGrid(Model.AllStaff,
                                           defaultSort: "First Name",
                                           rowsPerPage: 5, fieldNamePrefix: "",
                                           canPage: true, canSort: true,
                                           pageFieldName: "Page", sortFieldName: "srt"
                                           );  
}
<table cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>
            @grid.Table(tableStyle: "listing-border", headerStyle: "gridhead", footerStyle: "paging", rowStyle: "td-dark", alternatingRowStyle: "td-light",
                                columns:
                                    grid.Columns(

                                        grid.Column("FirstName", "First Name", style: "colFirstName"),
                                        grid.Column("LastName", "Last Name", style: "colLastName"),
                                        grid.Column("AddressLine1", "AddressLine1", style: "colAddressLine1"),
                                        grid.Column("Email", "Email", style: "colEmail"),
                                        grid.Column("Postcode", "Postcode", style: "colContactType"),
                                        grid.Column(header: "Edit", format: @<text><a href="@Url.Action("Edit", "Staff", new { id = item.id })" >Edit</a></text>, style: "colOperation"),
                                        grid.Column(header: "Delete", format: @<text>@Ajax.ActionLink("Delete", "Delete", new { id = item.id, Page = grid.PageIndex + 1 }, new AjaxOptions
                                                                                {
                                                                                    UpdateTargetId = "DivGrid",
                                                                                    InsertionMode = InsertionMode.Replace,
                                                                                    OnBegin = "ConfirmDelete()"
                                                                                })</text>, style: "colOperation")
                                                                     ))
        </td>
    </tr>
</table>
@LocalHelpers.DoAjaxPager(Ajax,new AjaxOptions
                                                    {
                                                        UpdateTargetId = "DivGrid",
                                                        InsertionMode = InsertionMode.Replace,
                                                        LoadingElementId = "resultLoadingDiv"
                                                    }, Html, "ReloadGrid", grid, 10, new { CurrentFilter = ViewBag.CurrentFilter })


<script type="text/javascript">
    function ConfirmDelete() {
        return confirm("Are you sure you want to delete this staff?");
    }
</script>
